//
//  EntryViewController.m
//  MyVirtualDiary
//
//  Created by Alexander Wallis on 12.07.13.
//  Copyright (c) 2013 Alexander Wallis. All rights reserved.
//

#import "EntryViewController.h"
#import "AppDelegate.h"
#import "Entry.h"

@interface EntryViewController ()

@end

@implementation EntryViewController
@synthesize titleLabelField, dateLabelField;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    NSManagedObjectContext *context = [[self appDelegate]managedObjectContext];
    Entry *entry = (Entry *)[context existingObjectWithID:self.entryID error:nil];
    
    titleLabelField.text = entry.titel;
    
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
    [dateFormatter setDateFormat:@"yyyy-MM-dd"];
    dateLabelField.text = [dateFormatter stringFromDate:entry.date];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - private methods
-(AppDelegate *)appDelegate{
    return (AppDelegate *)[[UIApplication sharedApplication]delegate];
}

-(IBAction)cancel:(id)sender{
    [self dismissViewControllerAnimated:YES completion:nil];
}

-(IBAction)edit:(id)sender{

}

@end
